import React, { Component } from "react";

export default class Home extends Component {
  constructor() {
    super();
    this.state = {
      num: 10,
      list: [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }],
    };
  }
  add = () => {
    this.setState({
      num: this.state.num + 1,
    });
  };

  render() {
    return (
      <div>
        Home 数据为{this.state.num}
        <button
          onClick={() => {
            this.add();
          }}
        >
          修改
        </button>
        <button
          onClick={() => {
            this.props.history.push("/mine");
          }}
        >
          点击跳转
        </button>
        {this.state.list.map((item) => {
          return <div key={item.id} onClick={()=>{
           this.props.history.push("/detail/"+item.id)
          }}>编号 {item.id}</div>;
        })}
      </div>
    );
  }
}
